package com.design.iterator;

public class ClassRoomIterator implements TIerator{

    private ClassRoom  classroom;
    private int index;

    public ClassRoomIterator(ClassRoom classRoom){
        this.classroom=classRoom;
        this.index=0;
    }

    @Override
    public boolean hasNext() {
        if (this.index<classroom.getLength()){
            return true;
        }
        return false;
    }

    @Override
    public Object next() {
        Student student = classroom.getStudent(index);
        index++;
        return student;
    }
}
